<?php

namespace App\Web\Controllers;

use App\Http\Controllers\WebController;
use App\Services\CategoryService;
use App\Services\FileService;
use Illuminate\Http\Request;

class UserController extends WebController
{
    function __construct(){
        $this->middleware('auth');
    }

    /**
     * 创建主题
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function newTopic(
        CategoryService $categoryService,
        FileService $fileService
    ){
        $uploads_files = \Session::get('uploads_files');
        $ids = empty($uploads_files[csrf_token()])?[]:$uploads_files[csrf_token()];
        $file_list = $fileService->getFilesByIds($ids);

        return view('web/user/new_topic')
            ->with('right_sidebar_hidden', true)
            ->with('categories', $categoryService->getCategoriesByPid())
            ->with('file_list', $file_list);
    }
}
